import copy
import time
import locale


class ListMethod:

    @staticmethod
    def getDifference(list_1: list, list_2: list, return_key='', ignore_key=''):
        list_a = copy.deepcopy(list_1)
        list_b = copy.deepcopy(list_2)
        if ignore_key:
            for x in list_a + list_b:
                del x[ignore_key]
        temp_list_index = []
        wrapper = 0
        for a in list_a:
            loop = 0
            temp_index = []
            for b in list_b:
                if a == b:
                    temp_index.append(loop)
                    temp_list_index.append(wrapper)
                    break
                loop += 1
            if len(temp_index) > 1:
                temp_index.sort(reverse=True)
            for x in temp_index:
                del list_b[x]
            wrapper += 1
        temp_list_index.sort(reverse=True)
        for x in temp_list_index:
            del list_a[x]
        res = [x[return_key] for x in list_a]
        return set(res)


class DateMethod:

    @staticmethod
    def dateToInt(date_str: str):
        locale.setlocale(locale.LC_ALL, '')
        time_array = time.strptime(date_str, '%Y/%m/%d %H:%M:%S')
        # 转换为时间戳
        time_stamp = int(time.mktime(time_array))
        return time_stamp

    @staticmethod
    def intToDate(date_int: int):
        time_array = time.localtime(date_int)
        other_style_time = time.strftime('%Y/%m/%d %H:%M:%S', time_array)
        return other_style_time
